<template>
  <Form
    name="dictForm"
    ref="formDict"
    :labelCol="labelCol"
    :wrapperCol="wrapperCol"
    @finish="onToolFinish"
    :initialValues="currentForm"
  >
      <Card style="width: 100%;">
    <Form name="user" ref="form" :labelCol="labelCol" :wrapperCol="wrapperCol">
      <Row>
        <Col :span="12">
          <FormItem name="resourceType" label="项目金额">
            <Input placeholder="请输入项目金额" style="width: 100%" />
          </FormItem>
        </Col>
        <Col :span="12">
          <FormItem name="resourceType" label="项目金额">
            <Input placeholder="请输入项目金额" style="width: 100%" />
          </FormItem>
        </Col>
      </Row>
      <Row>
        <Col :span="12">
          <FormItem name="resourceIps" label="项目名称">
            <Input placeholder="请输入项目名称" style="width: 100%" />
          </FormItem>
        </Col>
        <Col :span="12">
          <FormItem name="groupNamed" label="委托单位类型">
             <Select placeholder="资源类型" style="width: 100%">
              <Option label="内部" value="内部" />
              <Option label="公开" value="公开" />
            </Select>
          </FormItem>
        </Col>
      </Row>
      <Row>
        <Col :span="12">
          <FormItem name="resourceIpw" label="委托单位">
            <Input placeholder="请输入委托单位" style="width: 100%" />
          </FormItem>
        </Col>
        <Col :span="12">
          <FormItem name="groupNameh" label="项目类型">
             <Select placeholder="资源类型" style="width: 100%">
              <Option label="内部" value="内部" />
              <Option label="公开" value="公开" />
            </Select>
          </FormItem>
        </Col>
      </Row>
      <Row>
        <Col :span="12">
          <FormItem name="resourceIp" label="项目密级">
             <Select placeholder="资源类型" style="width: 100%">
              <Option label="内部" value="内部" />
              <Option label="公开" value="公开" />
            </Select>
          </FormItem>
        </Col>
      </Row>
      <Row>
        <Col :span="24">
          <FormItem name="resourceIp" label="项目描述" :labelCol="labelColW" :wrapperCol="wrapperColW">
             <TextArea
              placeholder="请输入"
              style="width: 100%"
              allowClear
              @input="onInput"
            />
          </FormItem>
        </Col>
        源应用信息
      </Row>
      <Row>
        <Col :span="12">
          <FormItem name="resourceIp" label="应用名称">
            <Input placeholder="请输入应用名称" style="width: 100%" />
          </FormItem>
        </Col>
        <Col :span="12">
          <FormItem name="groupName" label="数据量大小">
            <Input placeholder="数据量大小" style="width: 100%" />
          </FormItem>
        </Col>
      </Row>
      <Row>
        <Col :span="12">
          <FormItem name="resourceIp" label="应用架构">
            <Input placeholder="请输入应用架构" style="width: 100%" />
          </FormItem>
        </Col>
        <Col :span="12">
          <FormItem name="groupName" label="源库类型">
             <Select placeholder="资源类型" style="width: 100%">
              <Option label="内部" value="内部" />
              <Option label="公开" value="公开" />
            </Select>
          </FormItem>
        </Col>
      </Row>
      <Row>
        <Col :span="12">
          <FormItem name="resourceIp" label="中间件">
            <Input placeholder="请输入中间件" style="width: 100%" />
          </FormItem>
        </Col>
        <Col :span="12">
          <FormItem name="groupName" label="详细应用调研信息">
            <Input placeholder="详细应用调研信息" style="width: 100%" />
          </FormItem>
        </Col>
      </Row>
      <Row>
        <Col :span="12">
          <FormItem name="resourceIp" label="特性或技术" :wrapperCol="{span: 24}" style="text-align: right">
            <!-- <Input placeholder="请输入特性或技术" style="width: 100%" /> -->
             <Transfer
              :dataSource="mockDataCom"
              :titles="['待选择的类型', '使用的类型']"
              :targetKeys="['demo1-1']"
            />
          </FormItem>
        </Col>
        <Col :span="12">
          <FormItem name="groupName" label="详细数据库调研信息">
            <Input placeholder="详细数据库调研信息" style="width: 100%" />
          </FormItem>
        </Col>
      </Row>
      目标信息
      <Row>
        <Col :span="12">
          <FormItem name="resourceIp" label="项目负责人">
            <Input placeholder="项目负责人" style="width: 100%" />
          </FormItem>
        </Col>
        <Col :span="12">
          <FormItem name="groupName" label="厂商参与人员">
            <Input placeholder="厂商参与人员" style="width: 100%" />
          </FormItem>
        </Col>
      </Row>
      <Row>
        <Col :span="12">
          <FormItem name="resourceIp" label="项目负责人电话">
            <Input placeholder="项目负责人电话" style="width: 100%" />
          </FormItem>
        </Col>
        <Col :span="12">
          <FormItem name="groupName" label="厂商负责人电话">
            <Input placeholder="厂商负责人电话" style="width: 100%" />
          </FormItem>
        </Col>
      </Row>
      <Row>
        <Col :span="12">
          <FormItem name="resourceIp1" label="目标产品">
            <Cascader
              style="width: 100%"
              v-model="modelValue"
              :options="options"
              @update:modelValue="updateModel"
            />
          </FormItem>
        </Col>
        <Col :span="12">
          <FormItem name="groupName" label="项目预期工期">
            <Input placeholder="项目预期工期" style="width: 100%" />
          </FormItem>
        </Col>
      </Row>
      <Row>
        <Col :span="12" :offset="12">
          <FormItem name="groupName3" label="拟用解决方案">
            <Cascader
                  style="width: 100%"
                  v-model="modelValue"
                  :options="options"
                  @update:modelValue="updateModel"
                />
          </FormItem>
        </Col>
      </Row>
      <Row>
        <Col :span="24">
          <FormItem name="groupName" label="其他要求" :wrapperCol="wrapperColW" :labelCol="labelColW">
             <TextArea
              placeholder="请输入"
              style="width: 100%;"
              allowClear
              @input="onInput"
            />
          </FormItem>
        </Col>
      </Row>
      <Row>
        <Col :span="24">
          <FormItem :wrapperCol="24" style="text-align: center">
            <Button type="primary" size="md" style="width: 100px;">提交</Button>
            <Button style="margin-left: 20px;width: 100px;" size="md">重置</Button>
          </FormItem>
        </Col>
      </Row>
    </Form>
  </Card>
  </Form>
</template>

<script>
import { listType, getType, delType, addType, updateType, refreshCache } from "@/api/system/dict/type";
import { Message } from "@uni/vue";
export default {
  dicts: ['resource_type'],
  props: {
    id: {
      default: "",
    },
    currentRow: {
      default: () => {},
    },
  },
  data() {
    return {
      labelCol: {
        span: 8,
      },
      wrapperCol: {
        span: 16,
      },
      currentForm: {
        resourceNumber: this.currentRow.resourceNumber,
        resourceName: this.currentRow.resourceName,
        resourceType: this.currentRow.resourceType,
        status: this.currentRow.status == "0" ? "0" : "1",
        fatoryName: this.currentRow.fatoryName,
        ipAddress: this.currentRow.ipAddress,
        address:  this.currentRow.address,
        remark:  this.currentRow.remark,
      },
      dictNameRules: [{ required: true, message: "请输入字典名称" }],
      dictTypeRules: [{ required: true, message: "字典类型不能为空" }],
      roleOptions: [],
    };
  },
  methods: {
    handleCancel() {
      this.$emit("handleCancel");
    },
    sumbitForm() {
      this.$refs.formDict.submit();
    },
    onToolFinish(formData) {
      formData.status = formData.status === "0" ? "0" : "1";
      if (this.id) {
        formData.dictId = this.id;
        updateType(formData).then((response) => {
          if (response.code == 200) {
            Message.success({ text: "修改成功" });
            this.$emit("handleCancel");
          } else {
            Message.error({ text: "修改失败" });
          }
        });
      } else {
        addType(formData).then((response) => {
          if (response.code == 200) {
            Message.success({ text: "新增成功" });
            this.$emit("handleCancel");
          } else {
            Message.error({ text: "新增失败" });
          }
        });
      }
    },
  },
};
</script>
<style lang="scss" scoped>
::v-deep .uni-modal-body {
  padding: 0;
}
::v-deep .uni-modal-footer {
  display: none;
}
::v-deep .uni-card-title {
  display: none;
}
</style>